<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<?php $this->layout = "//layouts/column1"; ?>
<?php
if (!Yii::app()->user->isGuest && !Yii::app()->user->isAdmin()) {
    $usermodal = $_SESSION['usermodal'];
    if ($usermodal == NULL) {
        ?>
<!--        <div id="shade"></div>
        <div id="modal">
            <a id="modal_close" class="modal-close" href="#"></a>
            <div style="padding: 20px; border: 1px solid gray; height: 400px; width: 550px;">
                <h1>
                    We apologize to our clients who have tried to deposit but faced problems, this is due to changes we are bringing to improve. We suggest the clients in such situation if you faced any problem please email us with your payment processor number and account number to support@viewinvesta.com
                    <br/><br/>
                    Please do not use same Perfect Money account to deposit from different user account.
                </h1>
                <img class="stock-img" style="height: 400px; width: 550px; border: 1px solid #ddd" src="<?php echo Yii::app()->request->baseUrl; ?>/images/egg-nest.jpg"></img>
            </div>    
        </div>
        <script type="text/javascript">
            var modal= document.getElementById('modal');
            var shade= document.getElementById('shade');
            if(shade != null){
                modal.style.display=shade.style.display= 'block';
            }
            document.getElementById('modal_close').onclick= function() {
                modal.style.display=shade.style.display= 'none';
            };

            // This code is a workaround for IE6's lack of support for the
            // position: fixed style.
            //
            if (!('maxHeight' in document.body.style)) {
                function modalsize() {
                    var top= document.documentElement.scrollTop;
                    var winsize= document.documentElement.offsetHeight;
                    var docsize= document.documentElement.scrollHeight;
                    shade.style.height= Math.max(winsize, docsize)+'px';
                    modal.style.top= top+Math.floor(winsize/3)+'px';
                };
                modal.style.position=shade.style.position= 'absolute';
                window.onscroll=window.onresize= modalsize;
                modalsize();
            }
        </script>-->
        <?php
        $_SESSION['usermodal'] = '1';
    }
}
?>

<div style="border: 1px solid #DDDDDD; background-color: #DDDDDD; height: 910px;">
    <h2 style="background-color: #EEEEEE;border-bottom: 1px solid gray;margin: 0;padding-top: 10px;text-align: center;">Dashboard</h2>
    <div style=" padding-left: 5px; padding-right: 5px;">
        <div style="height: 205px;">
            <div class="vi-user-segment" style="height: 370px; float: left; width: 100%; border: 1px solid #87D7A7;">
                <h3 style="padding-top: 10px; height: 30px; background-color: #87D7A7">General Status</h3> 
                <div class="fullcontent" style="padding: 10px;">
                    <?php if ($package) { ?>
                        <div class="info">
                            You've <strong>'<?php echo $package->name ?>'</strong> active package(s).             
                        </div>
                    <?php } else { ?>
                        <div class="info">
                            You've no package yet. <?php echo CHtml::link('Buy Package', array('memberPosition/deposit')); ?>
                        </div>
                    <?php } ?>
                    <div class="info">
                        <?php
                        $refAlink = Yii::app()->createAbsoluteUrl('member/signup', array('refkey' => $model->upline_key, 'type' => 'A'));
                        $refBlink = Yii::app()->createAbsoluteUrl('member/signup', array('refkey' => $model->upline_key, 'type' => 'B'));
                        $upline = Member::model()->findBYPk($model->upline_id)->username;
                        if ($upline == NULL) {
                            $upline = "{not set}";
                        }
                        ?>
                        <b>Your Upline:</b> <?php echo $upline; ?><br>
                        <b>Your Referral A Link:</b> <a style="font-size: 14px" href="<?php echo $refAlink ?>" ><?php echo $refAlink ?></a><br>
                        <b>Your Referral B Link:</b> <a style="font-size: 14px" href="<?php echo $refBlink ?>" ><?php echo $refBlink ?></a><br>
                        <?php
                        if($remainingday>0){
                        ?>
                            <span style="border: 1px solid gray; background: linear-gradient(to bottom, #0276DA, #134560) repeat scroll 0 0 rgba(0, 0, 0, 0); border-radius: 11px;color: #FFFFFF;font-size: 30px;padding-left: 5px;padding-right: 5px;">
                            <?php echo $remainingday; ?></span> <b>days remaining of the current package</b>
                        <?php 
                        }
                        ?>
                    </div>

                </div>    
            </div>            
        </div>
        <div class="vi-user-segment" style="height: 445px; float: left; width: 100%; border: 1px solid #87CEEB;">
            <h3 style="padding-top: 10px; height: 30px; background-color: #87CEEB">Member Status: <?php echo $model->username; ?></h3> 
            <div class="fullcontent" style="padding: 10px;">
                <?php
                $this->widget('zii.widgets.CDetailView', array(
                    'data' => $model,
                    'attributes' => array(
                        'first_name',
                        'last_name',
                        'email',
                        array(
                            'name' => 'secutiry_question_id',
                            'label' => 'Security Question',
                            'value' => SecurityQuestion::model()->findByPK($model->security_question_id)->question
                        ),
                        'security_answer',
                        'security_code',
                        array(
                            'name' => 'create_date',
                            'label' => 'Registration On',
                            'value' => Yii::app()->dateFormatter->format("d MMM y", $model->create_date)
                        ),
                        array(
                            'name' => 'active',
                            'label' => 'Account Status',
                            'value' => (($model->active == 0) ? 'Inactive' : 'Active' )
                        ),
                        array(
                            'name' => 'Payment Processors',
                            'type' => 'html',
                            'value' => getPaymentProcessorNames($model->memberAccounts),
                        ),
                    ),
                ));

                function getPaymentProcessorNames($data) {
                    $out = "<ul>";
                    foreach ($data as $record) {
                        $out = $out . "<li>" . CHtml::encode(PaymentProcessor::model()->findByPK($record->payment_processors_id)->name) ."(". $record->account1.")</li>";
                    }
                    $out = $out . "</ul>";
                    $out = $out . CHtml::link('Add / Update Payment Processors', array('member/updatepp'));
                    return $out;
                }
                ?>
            </div>    
        </div>
        
        <div class="clear"></div>
    </div>
</div>
